package com.xt.web;

import com.xt.entity.User;
import com.xt.service.HelloService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.Random;

/**
 * Created by TT on 2017/7/7.
 */
@RestController
public class ConsumerController {
    @Autowired
    RestTemplate restTemplate;
    @Autowired
    HelloService helloService;

    @RequestMapping(value = "ribbon-consumer",method = RequestMethod.GET)
    public String helloConsumer(){
        //return helloService.helloService();
        return helloService.hello();
    }
    @RequestMapping(value = "ribbon-user",method = RequestMethod.GET)
    //@ResponseBody
    public User ribbonUser(Integer userId){
        //return restTemplate.getForEntity("http://hello-service/user?userId={1}",String.class,userId).getBody();
        return new User();
    }
}
